package login.servlet;

import login.dao.UserDao;
import login.dao.UserDaoImpl;
import login.daomain.User;

import javax.security.auth.login.FailedLoginException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: Hasee
 * @Date: 2020-06-02 09:00:30
 */
@WebServlet("/zhuCe")
public class zhuCeServlet extends HttpServlet {
    private UserDaoImpl dao;
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String name=req.getParameter("name");
        String password=req.getParameter("password");
        User user=new User(name,password);
        int i=dao.zhuCe(user);
        if (i==1){
            System.out.println("注册成功");
        }else if(i==2){
            System.out.println("注册失败,用户已经注册");
        }else {
            System.out.println("注册失败");
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
}
